USE UsersDB
GO
create database UsersDB
 on primary
 (
	  name='UsersDB_data',--主数据逻辑名
	  filename='D:\Database\UsersDB_data.mdf', --主数据物理名
	  size=5mb,   --主数据初始化大小
	  maxsize=100mb,  --主数据增长上限
	  filegrowth=10%   --主数据增长量
 )
 log on
 (
	 name='UsersDB_log',  --日志文件的逻辑名
	 filename='D:\Database\UsersDB_log.ldf',  --日志文件的物理名
	 size=1mb,  --日志文件的初始化大小
	 filegrowth=1mb  --日志文件的增长量
 )

CREATE TABLE Userinfo(
	U_ID int IDENTITY(1,1) NOT NULL,
	U_Name varchar(25) NOT NULL,
	U_Sex varchar(2) NOT NULL,
	U_Age int NOT NULL,
	U_Phone varchar(18) NULL,
	U_Address varchar(50) NULL,
 ) 
GO
alter table Userinfo add constraint CK_Userinfo_U_Sex check(U_Sex='' or U_Sex='Ů')
GO
alter table Userinfo add constraint PK_Userinfo_U_ID primary key(U_ID)
GO
alter table Userinfo add constraint DF_Userinfo_U_Address  default ('ͥסַδд') FOR U_Address
GO

alter table Userinfo add constraint CK_U_Age CHECK  ((U_Age>=(1) AND U_Age<=(110)))
GO

alter table Userinfo add constraint CK_U_Phone CHECK  ((len(U_Phone)>(6)))
GO


INSERT INTO Userinfo(U_Name,U_Sex,U_Age,U_Address)
     VALUES('','',18,'޺')
GO
INSERT INTO Userinfo(U_Name,U_Sex,U_Age,U_Phone,U_Address)
     VALUES('','Ů',20,15958643214,'޺')
GO
INSERT INTO Userinfo(U_Name,U_Sex,U_Age,U_Phone,U_Address)
     VALUES('','',19,13525681212,'޺')
GO
INSERT INTO Userinfo(U_Name,U_Sex,U_Age)
     VALUES('','Ů',21)
GO
INSERT INTO Userinfo(U_Name,U_Sex,U_Age)
     VALUES('','Ů',20)
GO







